export type Shape = 'O' | 'I' | 'T' | 'L' | 'J' | 'S' | 'Z';

export const Shape = {
  O: <Shape>'O',
  I: <Shape>'I',
  T: <Shape>'T',
  L: <Shape>'L',
  J: <Shape>'J',
  S: <Shape>'S',
  Z: <Shape>'Z',
};

export const SHAPE_NAME_SEQ = <Shape[]>Object.keys(Shape);

const ShapeInfo: { [k: string]: [number, number][] } = {
  I: [[-2, -1], [-1, -1], [0, -1], [1, -1]],
  J: [[-1, -1], [-1, 0], [0, 0], [1, 0]],
  L: [[-1, 0], [0, 0], [1, 0], [1, -1]],
  O: [[-1, -1], [0, -1], [-1, 0], [0, 0]],
  S: [[1, -1], [0, -1], [0, 0], [-1, 0]],
  Z: [[-1, -1], [0, -1], [0, 0], [1, 0]],
  T: [[0, -1], [-1, 0], [0, 0], [1, 0]],
}

export const getShapeInfo = (shape: Shape) => ShapeInfo[shape]
  .map(coord => <[number, number]>coord.slice());